home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#49 (Oct 89)
/
DMP Source
/
src
/
AZGlue.asm
< prev
next >
Wrap
Assembly Source File
|
1989-01-02
|
6KB
|
261 lines
;;
;; Glue for Printer Driver code resource headers using Aztec C.
;; Since the Aztec linker has no "-m" option like the MPW
;; linker, different headers for the various code resources
;; are obtained using conditional assembly.
;;
;; Earle R. Horton. All rights reserved.
;; Tuesday, December 13, 1988
;;
;; Some of the Glue routines contain data. This is read-only!
;;
ifd driver
JIODone EQU $08fc
myDrvrFlags EQU $1c00 ; Control, Stat, NeedGoodBye
;;
;; The header for the 'DRVR' resource.
;;
public _myPrOpen ; open routine
public _myPrPrime ; prime
public _myPrControl ; control
public _myPrStatus ; status
public _myPrClose ; close
public _DriverEntry ;; 'DRVR' starts here.
_DriverEntry:
DC.W myDrvrFlags ; control and status enable only
DC.W 0 ; doesn't need time
DC.W 0 ; no events
DC.W 0 ; no menu
DC.W myPrOpenCall-_DriverEntry ; Offsets to driver routines.
DC.W myPrPrimeCall-_DriverEntry
DC.W myPrControlCall-_DriverEntry
DC.W myPrStatusCall-_DriverEntry
DC.W myPrCloseCall-_DriverEntry
DC.B 6,".Print" ; Driver name as Pascal string
DC.W 0 ; Zero for word-align.
dummyheader ; Make it look like a procedure for
LINK A6,#0 ; MacsBug
myPrOpenCall
PEA _myPrOpen ;; SP -> desired driver routine.
BRA.S CallDriver ;; Jump to interface to call real routine.
myPrPrimeCall
PEA _myPrPrime ;; Times 5.
BRA.S CallDriver
myPrControlCall
PEA _myPrControl
BRA.S CallDriver
myPrStatusCall
PEA _myPrStatus
BRA.S CallDriver
myPrCloseCall
PEA _myPrClose
CallDriver
MOVE.L A1,-(SP) ;; Push pointer to device control entry.
MOVE.L A0,-(SP) ;; Push pointer to parameter block.
MOVEA.L 8(SP),A0 ;; Get routine address.
JSR (A0) ;; Call driver routine.
;; Result is in D0.
MOVE.L (SP)+,A0 ;; Restore registers.
MOVE.L (SP)+,A1 ;; Note: C programs leave the stack alone.
ADDQ.W #$4,A7 ;; Fix up stack pointer.
BTST #$01,$0006(A0) ;; Immediate call?
BNE.S StdReturn ;; Yes, regular return.
MOVE.L JIODone,-(sp) ;; No, return via IODone
StdReturn
RTS
label ;; This is for MacsBug.
UNLK A6
RTS
DC.B 'DMP-110 '
;
; The rest of this module consists of read-only data.
;
baud300 EQU 380
baud600 EQU 189
baud1200 EQU 94
baud1800 EQU 62
baud2400 EQU 46
baud3600 EQU 30
baud4800 EQU 22
baud7200 EQU 14
baud9600 EQU 10
baud19200 EQU 4
baud57600 EQU 0
public _AOutName,_BOutName,_BaudRates,_prhireslf
;
; Handy storage place for constant strings and data which can be copied
; by the Driver routines.
;
_AOutName
DC.B 5,".AOut"
_BOutName
DC.B 5,".BOut"
_prhireslf
dc.b 3,26,27,"G"
EVEN
_BaudRates
DC.W baud300
DC.W baud600
DC.W baud1200
DC.W baud1800
DC.W baud2400
DC.W baud3600
DC.W baud4800
DC.W baud7200
DC.W baud9600
DC.W baud19200
DC.W baud57600
endc
;;
;; The header for the Chooser Device Package.
;;
ifd pack
public _device
BRA.S devicejump
deviceID
DC.W 0
Packname
DC.L $5041434B ; 'PACK'
IDnumber
DC.W $F000 ; -4096
Version
DC.W 1
Flags
DC.L $0C00E000
devicejump
JMP _device
endc
;;
;; The header for the Job and Style Dialogs code.
;;
ifd dialog
public _MyPrintDefault
public _MyPrStlDialog
public _MyPrJobDialog
public _MyPrStlInit
public _MyPrJobInit
public _MyPrDlgMain
public _MyPrValidate
public _MyPrJobMerge
bra _MyPrintDefault
bra _MyPrStlDialog
bra _MyPrJobDialog
bra _MyPrStlInit
bra _MyPrJobInit
bra _MyPrDlgMain
bra _MyPrValidate
bra _MyPrJobMerge
;;
;; Routines to call Pascal procedures which are known by address
;; and not by name. (ProcPtr glue).
;;
public _CallDlgInit,_CallItemProc
_CallDlgInit
_CallItemProc
MOVE.L (SP)+,A0 ; Pop return address.
MOVE.l (SP)+,A1 ; Pop actual function address.
MOVE.L A0,-(SP) ; Push return address.
JMP (A1) ; Call the Pascal Function
end
endc
;;
;; The header for the printing code.
;;
ifd print
public _myPrOpenDoc
public _myPrCloseDoc
public _myPrOpenPage
public _myPrClosePage
bra _myPrOpenDoc
bra _myPrCloseDoc
bra _myPrOpenPage
bra _myPrClosePage
public _NGetTrapAddress
_NGetTrapAddress
move.w $0004(a7),d0
move.b $0007(a7),d1
tst.b d1
beq.s ngettrapaddressret
dc.w $a746 ; GetTrapAddress,SYS
bra.s ngettrapaddressret
dc.w $a346 ; GetTrapAddress,TOOL
ngettrapaddressret
move.l a0,d0
rts
;
; The rest of this module consists of read-only data.
;
baud300 EQU 380
baud600 EQU 189
baud1200 EQU 94
baud1800 EQU 62
baud2400 EQU 46
baud3600 EQU 30
baud4800 EQU 22
baud7200 EQU 14
baud9600 EQU 10
baud19200 EQU 4
baud57600 EQU 0
public _AOutName,_BOutName,_BaudRates
;
; Handy storage place for constant strings and data which can be copied
; by the Driver routines.
;
_AOutName
DC.B 5,".AOut"
_BOutName
DC.B 5,".BOut"
EVEN
_BaudRates
DC.W baud300
DC.W baud600
DC.W baud1200
DC.W baud1800
DC.W baud2400
DC.W baud3600
DC.W baud4800
DC.W baud7200
DC.W baud9600
DC.W baud19200
DC.W baud57600
endc
;
; This section used by pack.c and pdriver.c.
;
PortBUse EQU $291
public _IsMPPOpen
_IsMPPOpen ;; Apparently left out of {clib}a.lib
moveq #0,d1
move.b PortBUse,d0
bmi.s ismppopenreturn
andi.b #$0f,d0
subq.b #1,d0
bne.s ismppopenreturn
moveq #1,d1
ismppopenreturn
move.b d1,4(a7)
rts
end